package com.ktg.mes.erpInventory.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ktg.mes.erpInventory.service.IErpInventoryService;
import com.ktg.mes.erpInventory.service.IT6ErpInventoryService;
import com.ktg.mes.md.domain.MdItem;
import com.ktg.mes.md.service.IMdItemService;
import com.ktg.mes.unit.sync.SyncModel;
import com.ktg.mes.unit.sync.service.IFromService;
import com.ktg.mes.unit.sync.service.IToService;
import com.ktg.mes.webSocket.NoticeWbsocketType;
import com.ktg.mes.webSocket.NoticeWebsocket;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ErpInventoryServiceImpl implements IErpInventoryService {
    @Autowired
    private IMdItemService iMdItemService;

    @Autowired
    private IT6ErpInventoryService it6ErpInventoryService;



    @Override
    public void syncDataListByLastIdFromErp() {
//        String lastId = "0";
//        // 处理 MesInventory 数据
//        String maxPubfts = iMdItemService.queryMaxPubfts();
//        if (StringUtils.isNotBlank(maxPubfts)) {
//            lastId = maxPubfts;
//        }
//        List<MdItem> list = it6ErpInventoryService.queryListByLastPubufts(lastId);
//        for (MdItem item : list) {
//            QueryWrapper<MdItem> dbWrapper = new QueryWrapper<>();
//            dbWrapper.select("id","inv_cat_code");
//            MdItem dbItem = iMdItemService.selectMdItemByCode(item.getItemCode());
//            if (dbItem != null && dbItem.getItemId() != null && dbItem.getItemId() > 0) {
//                // 不更新 inv_cat_code
//                item.setItemTypeCode(dbItem.getItemTypeCode());
//                item.setItemTypeId(dbItem.getItemTypeId());
//                item.setItemTypeName(dbItem.getItemTypeName());
//                iMdItemService.updateMdItemByCode(item);
//            }else {
//                iMdItemService.insertMdItem(item);
//            }
//        }
        iMdItemService.sysnStock();
    }



}
